package com.itheima.interface_case.students_manager;

public class ClassManager2 extends StudentOperator {
    @Override
    public void printStudents() {
        System.out.println("===========打印所有学生信息===========");
        for (int i = 0; i < this.students.size(); i++) {
            Student student = this.students.get(i);
            System.out.println(student.getName() + " -> " + student.getSex() + " -> " + student.getScore());
        }
        System.out.println("男同学有 " + Student.manCount + " 人");
        System.out.println("女同学有 " + Student.womanCount + " 人");
        System.out.println("共有 " + this.students.size() + " 人");

    }

    @Override
    public void printAvgScore() {
        System.out.println("===========打印平均成绩===========");
        int sum = this.students.get(0).getScore();
        int max = this.students.get(0).getScore();
        int min = this.students.get(0).getScore();
        for (int i = 1; i < this.students.size(); i++) {
            Student student = this.students.get(i);
            sum += student.getScore();
            if (max < student.getScore()) {
                max = student.getScore();
            }
            if (min > student.getScore()) {
                min = student.getScore();
            }
        }
        System.out.println("减去最高分和最低分后, 所有学生平均成绩为：" + (sum - max - min) / (this.students.size() - 2));
    }
}
